// 定义医院列表相关请求的函数
import { request } from '@/utils/http'
import {
  IhospitalListParams,
  IhospitalListRes,
  IdictList,
  IdepList,
  IscheduleRuleRes,
} from './model/hospitalListTypes'
// 获取医院设置表格数据
export function reqHospitalList({
  page,
  limit,
  hosname,
  hoscode,
  hostype,
  provinceCode,
  cityCode,
  districtCode,
  status,
}: IhospitalListParams) {
  // axios响应回来的数据类型,需要在调用axios函数发请求的时候传入进去,否则拿回来的数据ts检查无法知道里面都有哪些属性
  return request.get<any, IhospitalListRes>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      params: {
        hosname,
        hoscode,
        hostype,
        provinceCode,
        cityCode,
        districtCode,
        status,
      },
    }
  )
}

// 获取省数据的函数
export function reqProvinceList(dictCode: string = 'province') {
  return request.get<any, IdictList>(
    `/admin/cmn/dict/findByDictCode/${dictCode}`
  )
}
// 获取市或区或医院类型数据的函数
export function reqCityOrDistrictList(parentId: string) {
  return request.get<any, IdictList>(
    `/admin/cmn/dict/findByParentId/${parentId}`
  )
}

// 获取所有科室数据的函数
export function reqGetDepList(hoscode: string) {
  return request.get<any, IdepList>(`/admin/hosp/department/${hoscode}`)
}
// 获取排班规则
export function reqGetScheduleRules(
  page: number,
  limit: number,
  hoscode: string,
  depcode: string
) {
  return request.get<any, IscheduleRuleRes>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  )
}
